package com.qiwx.pigeon.presenter;

import com.qiwx.pigeon.base.BasePresenter;
import com.qiwx.pigeon.base.IBaseView;
import com.qiwx.pigeon.data.network.ApiManager;
import com.qiwx.pigeon.data.network.BaseResponse;
import com.qiwx.pigeon.data.network.ResponseSubscriber;
import com.qiwx.pigeon.data.params.CageParam;
import com.qiwx.pigeon.data.params.QueryWareHouseParam;
import com.qiwx.pigeon.data.vo.CageBeanVo;
import com.qiwx.pigeon.data.vo.QueryWareHouseBean;
import com.qiwx.pigeon.data.vo.pageinfo.PageInfo;
import com.qiwx.pigeon.viewinterface.IQueryWHView;

import java.lang.ref.WeakReference;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * @description
 * @Author qiwx
 * @Date 2020-05-04 21:17
 * 查询鸽场
 **/
public class QueryWHPresenter extends BasePresenter<IQueryWHView> {
    public QueryWHPresenter(WeakReference<IQueryWHView> from) {
        super(from);
    }

    public QueryWHPresenter(IQueryWHView from) {
        super(from);
    }

    //查询鸽笼
    public void queryWareHouseByPage(QueryWareHouseParam params) {
        ApiManager.getApiServer().queryWareHouseByPage(params)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new ResponseSubscriber<BaseResponse<PageInfo<QueryWareHouseBean>>>(true) {
                    @Override
                    public IBaseView getIView() {
                        return getView();
                    }

                    @Override
                    public void onSuccess(BaseResponse<PageInfo<QueryWareHouseBean>> response) {
                        getView().onQueryWareHouseSuccess(response.data);
                    }

                });
    }
}
